package com.p1.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.text.SimpleDateFormat;
import java.util.Date;

public class JsonUtil {
    public static String getjson(Object object,String dateformat) throws JsonProcessingException {
        //转为json数据,就需要用到jackson包下的ObjectMapper对象
        ObjectMapper mapper=new ObjectMapper();

        Date date=new Date();
        //利用java方法更改日期时间的格式
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        return mapper.writeValueAsString(sdf.format(date));
    }

}
